package com.ruoyi.cms.blog.controller;

import com.ruoyi.cms.blog.domain.CmsMode;
import com.ruoyi.cms.blog.service.ICmsModeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/cms/mode")
public class CmsModeController extends BaseController {
    private final ICmsModeService iCmsModeService;

    @GetMapping
    public AjaxResult getCmsMode() {
        return AjaxResult.success(iCmsModeService.getCmsMode());
    }

    /**
     * 新增金额模式
     */
    @PostMapping
    public AjaxResult add(@RequestBody CmsMode cmsMode) {
        return toAjax(iCmsModeService.insert(cmsMode));
    }

    @PutMapping
    public AjaxResult update(@RequestBody CmsMode mode) {
        return toAjax(iCmsModeService.update(mode));
    }

    /**
     * 根据ID查询
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(iCmsModeService.selectCmsModeById(id));
    }
}
